---
title: Identifying Features
description: Identifying features on a Dynamic Map Layer on click by querying the service. Click a feature to identify it. More information about Map Services can be found in the <a href="../api-reference/layers/dynamic-map-layer.html">L.esri.DynamicMapLayer</a> documentation.
layout: example.hbs
---

<style>
  #selectedFeatures {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    padding: 1em;
  }
  .leaflet-bar.map-text a {
    color: #79BD8F;
    display: inline;
  }
</style>

<div id="map"></div>
<div id="selectedFeatures" class="leaflet-bar map-text">Click on the map for Soil <a href="https://services.arcgisonline.com/arcgis/rest/services/Specialty/Soil_Survey_Map/MapServer">Order/ Sub-Order</a>
</div>
<script>
  var map = L.map('map', {
    minZoom: 5
  }).setView([38.5, -96.8], 6);
  L.esri.basemapLayer('Gray').addTo(map);

  var soil = L.esri.dynamicMapLayer({
    url: 'https://services.arcgisonline.com/arcgis/rest/services/Specialty/Soil_Survey_Map/MapServer',
    opacity: 0.7
  }).addTo(map);

  var identifiedFeature;
  var pane = document.getElementById('selectedFeatures');

  map.on('click', function (e) {
    pane.innerHTML = 'Loading';
    if (identifiedFeature){
      map.removeLayer(identifiedFeature);
    }
    soil.identify().on(map).at(e.latlng).run(function(error, featureCollection){
      // make sure at least one feature was identified.
      if (featureCollection.features.length > 0) {
        identifiedFeature = L.geoJSON(featureCollection.features[0]).addTo(map);
        var soilDescription =
          featureCollection.features[0].properties['Dominant Order'] +
          ' - ' +
          featureCollection.features[0].properties['Dominant Sub-Order'];
        pane.innerHTML = soilDescription;
      }
      else {
        pane.innerHTML = 'No features identified.';
      }
    });
  });
</script>
